package com.ex.ui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton; 
import javax.swing.SwingConstants;
import java.awt.Toolkit;
import java.awt.Color;
import java.awt.Window.Type;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class PersonFrame {

	private JFrame frame;
	private JTextField TbName; 
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					PersonFrame window = new PersonFrame();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public PersonFrame() {
		initialize();
	}
	public void show()
	{
		JFrame.setDefaultLookAndFeelDecorated(true);
		frame.show();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setResizable(false);
		frame.setType(Type.UTILITY);
		frame.setForeground(new Color(191, 205, 219));
		frame.setIconImage(Toolkit.getDefaultToolkit().getImage("C:\\Users\\Administrator\\Downloads\\1.jpg"));
		frame.setTitle("\u5C0F\u5B66\u751F\u6570\u5B66\u7EC3\u4E60\u5DE5\u5177_\u767B\u5F55");
		frame.setBounds(100, 100, 347, 181);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JLabel label = new JLabel("\u8BF7\u8F93\u5165\u4F60\u7684\u59D3\u540D\uFF1A");
		label.setBounds(23, 24, 99, 27);
		frame.getContentPane().add(label);
		
		TbName = new JTextField();
		TbName.setBounds(70, 61, 99, 21);
		frame.getContentPane().add(TbName);
		TbName.setColumns(10);
		
		JButton btnLogin = new JButton("\u8FDB\u5165");
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				frame.setVisible(false);  //隐藏当前窗口
				frame.dispose();//销毁当前窗口
				
				try { 
					MainWnd window = new MainWnd();
					window.show();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		btnLogin.setBounds(70, 92, 99, 23);
		frame.getContentPane().add(btnLogin);
		
		JLabel lblNewLabel = new JLabel("New label");
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		 
		lblNewLabel.setBounds(179, 16, 112, 101);
		frame.getContentPane().add(lblNewLabel);
		frame.setLocationRelativeTo(null);
	}
}
